<template>
        <div class="szTag-childlist" >
          <div class="szTag_contain">
             <div class="szTag-Tag" v-for="(list, index) in tagLists" :key="index">
              <div class="R-tag">
                <div class="R-tag-name">
                  <span @click="changeTagList(list.childrenlist)">{{list.name}}</span>
                </div>
              </div>
            </div>            
          </div>
            <div class="childlist-Tag_contain">
               <!-- <router-view></router-view> -->
               <tagListContain :tagListChidren="tagListChidren"></tagListContain>
            </div>
          </div>
</template>

<script>
import tagListContain from './tagListContain'
export default {
    name:'tagList',
    data() {
      return {
        tagListChidren:[]
      }
    },
    components:{
      tagListContain,
    },
    methods: {
      changeTagList(value){
        // 这里获取到了相应的点击的子列表
        this.$store.commit('menus/INIT_CHILDRENLISTS',JSON.parse(JSON.stringify(value)))
        if (value&&value instanceof Array) {
          // 使用数组合并的方法直接合并数组
          this.tagListChidren=[...value]
          // console.log("合并后的数组为:" ,this.tagListChidren);
        }
        return JSON.parse(JSON.stringify(value));
      },
      tagListContain_init(){
        //页面载入的时候初始化页面
        // this.$store.commit('menus/INIT_CHILDRENLISTS',JSON.parse(JSON.stringify(this.tagLists[0].childrenlist)))
        this.tagListChidren=[...this.tagLists[0].childrenlist]
      }
    },
    computed: {
      tagLists(){
        return this.$store.state.menus.tagList;
      },
      
    },
    created() {
      if (window.localStorage.getItem('tagList')) {
        // 当本地的taglis数据存在则将本地存储的taglist存入vuex
          this.$store.commit('menus/INIT_TAGLIST',JSON.parse(window.localStorage.getItem('tagList')))
      }
    },
    mounted() {
      this.tagListContain_init();
      // console.log("获取到的tagList",this.tagLists);
      // console.log('tagList[0]',this.tagLists[0].childrenlist)
    },
}
</script>

<style scoped>

/**
 *思政标签和子列表szTag-childlist 
 */
 .szTag-childlist{
  width: 100%;
  height: auto;
  display: flex;
  justify-content: flex-start;
  background-color: rgb(255, 255, 255);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 10px 10px 10px rgb(212, 212, 212);

 }
 .childlist-Tag_contain{
  width: 80%;
  height: auto;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  right: 0;
  display: inline-block;
}
.szTag_contain{
  width: 20%;
  position: relative;
  left: 0;
  padding: 20px;
  display: inline-block;
  border-right: 1px solid #e8e7e7;
  background-color: transparent;
}
 .szTag-Tag{
  width: 100%;
  align-content: flex-start;
 }
  .R-tag{
    height: 30px;
    line-height: 30px;
    cursor: pointer;
    margin-bottom: 10px;
    background-color: transparent;
  }
  .R-tag-name span{
    display: block;
    width: 100%;
    background-color: rgb(244, 244, 244);
  }
  .R-tag:hover{
    background-color: rgb(240, 240, 240);
  }
  .R-tag div:nth-child(1){
    flex: 6;
    height: 30px;
    position: relative;
  }
  .R-tag div:nth-child(2){
    flex: 1;
    height: 30px;
    position: relative;
  }
  .R-tag-name{
    padding-left: 10px;
    display: block;
    width: 100%;
    color: #666;
    background-color: rgb(244, 244, 244);
  }
 .icon_c{
  float: right;
  width: 20px;
  position: relative;
  color: #666;
 }
</style>